//
//  EBMUserSingle.m
//  eBondMall
//
//  Created by apple on 2020/4/22.
//  Copyright © 2020 zhaoshijie. All rights reserved.
//

#import "EBMUserSingle.h"
#import "SJAppInformationTool.h"



@implementation EBMUserSingle



/// 创建用户信息
+ (instancetype)shareUserSingle
{
    
    static EBMUserSingle *userSingle;
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        
        userSingle = [[EBMUserSingle alloc]init];
        
        
        /// 获取本地存储数据
        [userSingle gainUserInformationInLocal];
        
        
//        userSingle.token = @"bearer 8e714e64-f731-4942-817a-70dc613b138c";
        
        
        
    });
    
    return userSingle;
}




/// 请求用户信息
/// @param successBlock 请求成功
- (void)requestDataInUserInformationWithSuccessBlock:(void(^)(void))successBlock
{
    [self requestDataInUserInformationWithSuccessBlock:successBlock loadView:nil];
}



/// 请求用户信息
/// @param successBlock 请求成功
/// @param loadView 加载位置
- (void)requestDataInUserInformationWithSuccessBlock:(void(^)(void))successBlock
                                            loadView:(UIView *)loadView
{
    
    
//    NSString *urlString = Myself_member;
    NSString *urlString = @"";
    
     
    [EBMRequest GETRequestTakeDataWithUrlString:urlString headerDic:nil parameters:nil loadView:loadView tableView:nil successBlock:^(id result) {
        
        
        KUserSinge.account = result[@"account"];
        
        
        [KUserSinge userInformationInLocalStorage];
        
        
        if(successBlock)
        {
            successBlock();
        }
        
//        [self loginKIM];
        
    } serverErrorBlock:nil failBlock:nil];
    
    
    
}




/// 获取弱应用的用户对象
+ (EBMUserSingle *)gainWeakUserSingle
{
    __weak EBMUserSingle *userSingle = [EBMUserSingle shareUserSingle];
    
    return userSingle;
    
}




/// 判断是否登录
- (BOOL)isLogin
{
    if(self.token)
    {
        return YES;
    }
    else
    {
        return NO;
    }
}






@end
